let findDuplicates = function(nums){
    let results = []
    for(let i=0; i<nums.length; i++){
       let index = Math.abs(nums[i]) - 1
       if(nums[index] > 0){
            nums[index] *= -1
       } else{
            results.push(Math.abs(nums[i]))
       }
       console.log(nums)
    }
    console.log(results)
}

findDuplicates([4,3,2,7,8,2,3,1])